﻿using System;
using UnityEngine;

namespace SteeringBehaviors
{
	// Token: 0x0200021A RID: 538
	public class Arrive : SteerBehavior
	{
		// Token: 0x06000B4D RID: 2893 RVA: 0x0005F15C File Offset: 0x0005D35C
		public Arrive(MovementCharacter agent, IKinematic target) : base(agent, target)
		{
		}

		// Token: 0x17000158 RID: 344
		// (get) Token: 0x06000B4E RID: 2894 RVA: 0x0005F171 File Offset: 0x0005D371
		public float targetRadius
		{
			get
			{
				return this.agent.scale * 0.2f;
			}
		}

		// Token: 0x17000159 RID: 345
		// (get) Token: 0x06000B4F RID: 2895 RVA: 0x0005F184 File Offset: 0x0005D384
		public float slowRadius
		{
			get
			{
				return this.agent.scale * 0.5f;
			}
		}

		// Token: 0x06000B50 RID: 2896 RVA: 0x0005F198 File Offset: 0x0005D398
		public override SteeringOutput GetSteering()
		{
			SteeringOutput steeringOutput = new SteeringOutput();
			Vector3 vector = this.target.position - this.agent.transform.position;
			vector.y = 0f;
			float magnitude = vector.magnitude;
			if (magnitude < this.targetRadius)
			{
				this.agent.Stop();
				return steeringOutput;
			}
			float d;
			if (magnitude > this.slowRadius)
			{
				d = this.agent.MaxSpeed;
			}
			else
			{
				d = this.agent.MaxSpeed * magnitude / this.slowRadius;
			}
			Vector3 a = vector;
			a.Normalize();
			a *= d;
			steeringOutput.linear = a - this.agent.velocity;
			steeringOutput.linear /= this.timeToTarget;
			if (steeringOutput.linear.magnitude > this.agent.MaxAccel)
			{
				steeringOutput.linear.Normalize();
				steeringOutput.linear *= this.agent.MaxAccel;
			}
			return steeringOutput;
		}

		// Token: 0x04001065 RID: 4197
		public float timeToTarget = 0.1f;
	}
}
